Skip to content

Normalize .. and . in diagnostic file paths#155569

Open
arferreira wants to merge 1 commit intorust-lang:mainfrom
arferreira:normalize-diagnostic-paths
Open

Normalize .. and . in diagnostic file paths#155569
arferreira wants to merge 1 commit intorust-lang:mainfrom
arferreira:normalize-diagnostic-paths

Conversation

@arferreira
Copy link
Copy Markdown
Contributor

@arferreira arferreira commented Apr 20, 2026

Fixes #51349

Lexically normalize . and .. in file paths when rendering diagnostics, so errors show foo.rs instead of sub/../foo.rs. Normalization is scoped to the new FileNameDisplayPreference::Diagnostics variant used by SourceMap::filename_for_diagnostics; file!(), debuginfo, and remapped/local/short paths are unchanged.

Uses the unstable Path::normalize_lexically, canonicalize is avoided because it turns relative paths absolute, which broke the previous attempt in #83345. Paths that normalize_lexically rejects (leading escapes, net-negative ..) fall back to the raw path and don't occur in practice for the diagnostic paths this PR targets. Compiletest gains a $DIR/.. substitution so existing .stderr files that referenced auxiliary paths above $DIR keep matching.

Previous attempt was #68654.

r? @estebank

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 20, 2026

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 20, 2026
@rust-log-analyzer

This comment has been minimized.

@arferreira arferreira force-pushed the normalize-diagnostic-paths branch from 72beb68 to e02a2f9 Compare April 20, 2026 17:46
Comment thread compiler/rustc_span/src/lib.rs Outdated
Comment thread compiler/rustc_span/src/lib.rs Outdated
@arferreira arferreira force-pushed the normalize-diagnostic-paths branch from e02a2f9 to 7e7055d Compare April 20, 2026 23:18
@arferreira arferreira force-pushed the normalize-diagnostic-paths branch from 7e7055d to b0cb45e Compare April 21, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compiler error message shows the error path containing parent directory identifier ( /../ )

5 participants